package com.fauks.ssm.mybatis;

import com.fauks.ssm.mybatis.bean.University;
import com.fauks.ssm.mybatis.mapper.UniAndCouMany2ManyMaper;
import com.fauks.ssm.mybatis.utils.MyBatisUtils;
import org.apache.ibatis.session.SqlSession;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * 自关联查询
 */
public class _06ManyToMany {

    private SqlSession sqlSession;
    private UniAndCouMany2ManyMaper many2ManyMaper;

    @Before
    public void initDao() {
        sqlSession = MyBatisUtils.getSqlSession();
        many2ManyMaper = sqlSession.getMapper(UniAndCouMany2ManyMaper.class);
    }

    @After
    public void closeSession() {
        if (sqlSession != null) {
            sqlSession.close();
        }
    }

    @Test
    public void testGetChildByParent() {
        University universityById = many2ManyMaper.getUniversityById(1);
        System.out.println(universityById);
    }

}
